#ifndef CAFFEINE_UTILITY_SINGLETON_HPP
#define CAFFEINE_UTILITY_SINGLETON_HPP

#include "Common.hpp"

namespace Utility
{
	template< typename Type >
	class Singleton
	{
	public:
		static Type *Get( void )
		{
			if ( instance )
			{
				return instance;
			}
			else
			{
				instance = new Type;
				return instance;
			}
		}

		static void Release( void )
		{
			if ( instance )
			{
				delete instance;
			}
		}
	private:
		static Type *instance;
	};

	template< typename Type >
	Type *Singleton< Type >::instance = nullptr;
}

#endif //CAFFEINE_UTILITY_SINGLETON_HPP